package com.xrz.sxm.base.utils;

import java.io.File;

import android.os.Environment;

public class FileUtils extends com.xrz.sxm.base.receiver.FileReceiver {

	private static FileUtils mUtils;
	/**
	 * sd卡状态 true：表示可用
	 */
	private boolean state;

	public static FileUtils getInstant() {
		if (mUtils == null)
			mUtils = new FileUtils();
		return mUtils;
	}

	/**
	 * 创建文件夹
	 * 
	 * @param paths
	 */
	public void createFolder(String... paths) {
		File f = null;
		for (String p : paths) {
			f = new File(p);
			if (!f.exists())
				f.mkdirs();
			f = null;
		}
	}

	/**
	 * 获取sd卡是否可用
	 * @return
	 */
	public boolean isSDcardAvlive() {
		if (this.state == false) {
			return Environment.getExternalStorageState().equals(
					Environment.MEDIA_MOUNTED);
		}
		return state;
	}

	@Override
	protected void onSDcardState(boolean state) {
		this.state = state;
	}
}
